Class Iis
	Private objWmi
	Private blnConnect

	Private Sub Class_Initialize()
		Set objWmi = New Wmi
		
		blnConnect = False
		objWmi.WmiPath = "\root\microsoftiisv2"
	End Sub
	
	Public Property Let Login(ByVal varValue)
		objWmi.Login = varValue
	End Property
	
	Public Property Let Password(ByVal varValue)
		objWmi.Password = varValue
	End Property
	
	Public Property Let IpAddress(ByVal varValue)
		objWmi.IpAddress = varValue
	End Property
	
	Public Sub Connect()
		objWmi.Connect()
		
		blnConnect = True
	End Sub
	
	Public Sub StartAppPool(ByVal strAppPoolName)
		If Not blnConnect Then
			Err.Raise 5000, "Services->StopService", "Error Description"
		End If
	
		Set colItems = objWmi.WmiService.ExecQuery("Select * From IIsApplicationPool Where Name = " & "'W3SVC/AppPools/" & strAppPoolName & "'")
		
		For Each objItem in colItems
			objItem.Start()
			
			Exit For
		Next
	End Sub
	
	Public Sub StopAppPool(ByVal strAppPoolName)
		If Not blnConnect Then
			Err.Raise 5000, "Services->StopService", "Error Description"
		End If
	
		Set colItems = objWmi.WmiService.ExecQuery("Select * From IIsApplicationPool Where Name = " & "'W3SVC/AppPools/" & strAppPoolName & "'")
		
		For Each objItem in colItems
			objItem.Stop()
			
			Exit For
		Next
	End Sub
	
	Public Sub RecycleAppPool(ByVal strAppPoolName)
		If Not blnConnect Then
			Err.Raise 5000, "Services->StopService", "Error Description"
		End If
	
		Set colItems = objWmi.WmiService.ExecQuery("Select * From IIsApplicationPool Where Name = " & "'W3SVC/AppPools/" & strAppPoolName & "'")
		
		For Each objItem in colItems
			objItem.Recycle()
			
			Exit For
		Next
	End Sub
	
	Public Sub AppPoolState(ByVal strAppPoolName)
		' To get the state of appropriate AppPool: IIsApplicationPoolSetting
	End Sub
End Class